-
Notifications
You must be signed in to change notification settings - Fork 1.8k
out_loki: add stuctured_metadata_map_keys #9530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
out_loki: add stuctured_metadata_map_keys #9530
Conversation
7f1db76 to
a9cdcad
Compare
a9cdcad to
e9fee7d
Compare
Hey @edsiper, what kind of JSON do you need? This only touches the Loki output, so I could include:
Would this be okay? |
The below is the results for running this with {
"message": "simple log generated",
"logger": "my.logger",
"level": "INFO",
"hostname": "localhost",
"my_map_of_attributes_1": {
"key_1": "hello, world!",
"key_2": "goodbye, world!"
},
"my_map_of_maps_1": {
"root_key": {
"sub_key_1": "hello, world!",
"sub_key_2": "goodbye, world!"
}
}
}I used the following to query Loki: This is the output with the option enabled. As you can see, the [
{
"stream": {
"hostname": "localhost",
"key_1": "hello, world!",
"key_2": "goodbye, world!",
"level": "INFO",
"logger": "my.logger",
"service_name": "test",
"sub_key_1": "hello, world!",
"sub_key_2": "goodbye, world!"
},
"values": [
[
"1740489069234881956",
"simple log generated"
]
]
}
]And here is the output with the feature not enabled. This also removes [
{
"stream": {
"hostname": "localhost",
"level": "INFO",
"logger": "my.logger",
"service_name": "test"
},
"values": [
[
"1740489174234932650",
"message=\"simple log generated\" my_map_of_attributes_1=\"map[key_1:\"hello, world!\" key_2:\"goodbye, world!\"]\" my_map_of_maps_1=\"map[root_key:\"map[sub_key_1:\"hello, world!\" sub_key_2:\"goodbye, world!\"]\"]\""
]
]
}
] |
84faf4c to
717081e
Compare
* Adds stuctured_metadata_map_keys config to dynamically populate stuctured_metadata from a map * Add docker-compose to test loki backend Signed-off-by: Greg Eales <[email protected]>
Signed-off-by: Greg Eales <[email protected]>
717081e to
2ebd4ce
Compare
|
Ignore the container failures - it is a permissions problem I think for forks, they build ok but fail to push. |
|
Build and pushed manually: ghcr.io/fluent/fluent-bit:pr-9530 docker buildx build -t ghcr.io/fluent/fluent-bit:pr-9530 --platform=linux/amd64 --target=production --push=true . |
This image is now available for us, and my testing confirms it is working as expected 👍 |
|
thanks folks for hard working on this |
Resolves #9463
The below is the results for running this with
/docker_compose/loki-grafana-structured_metadata_map/, which has input{ "message": "simple log generated", "logger": "my.logger", "level": "INFO", "hostname": "localhost", "my_map_of_attributes_1": { "key_1": "hello, world!", "key_2": "goodbye, world!" }, "my_map_of_maps_1": { "root_key": { "sub_key_1": "hello, world!", "sub_key_2": "goodbye, world!" } } }I used the following to query Loki:
curl http://localhost:3100/loki/api/v1/query_range --data-urlencode 'query={service_name="test"}' --data-urlencode 'limit=1' --data-urlencode 'step=5' | jq '.data.result'This is the output with the option enabled. As you can see, the
streamsection contains the keys for the structured metadata:[ { "stream": { "hostname": "localhost", "key_1": "hello, world!", "key_2": "goodbye, world!", "level": "INFO", "logger": "my.logger", "service_name": "test", "sub_key_1": "hello, world!", "sub_key_2": "goodbye, world!" }, "values": [ [ "1740489069234881956", "simple log generated" ] ] } ]And here is the output with the feature not enabled. This also removes
my_map_of_attributes_1andmy_map_of_maps_1fromremove_keys. As you can see,key_1,key_2,sub_key_1andsub_key_2are no longer in thestream` section:[ { "stream": { "hostname": "localhost", "level": "INFO", "logger": "my.logger", "service_name": "test" }, "values": [ [ "1740489174234932650", "message=\"simple log generated\" my_map_of_attributes_1=\"map[key_1:\"hello, world!\" key_2:\"goodbye, world!\"]\" my_map_of_maps_1=\"map[root_key:\"map[sub_key_1:\"hello, world!\" sub_key_2:\"goodbye, world!\"]\"]\"" ] ] } ]Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
fluent/fluent-bit-docs#1527
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.